import { defineStore } from 'pinia'
import { getToken, removeToken } from '@/utils/auth.ts'
import { ref } from 'vue'
 
const useDemoStore = defineStore('demo', () => {
  const isScreen = ref(true)
  const token = ref(getToken())
 
  const increment = (value: boolean) => {
    isScreen.value = value
  }

  // remove token
  const resetToken = (value: string) => {
    // return new Promise<void>(resolve => {
      token.value = ''
      // 清除本地存储的token
      localStorage.removeItem('token');
      removeToken()
      // resolve()
    // })
  }
 
  return {
    isScreen,
    increment,
    resetToken
  }
})
 
export default useDemoStore